﻿using System;
using System.Data;
using System.Configuration;
using System.Xml.Serialization;
using System.Web;

/// <summary>
/// crlnet;
///RewriteConfig 的摘要说明
/// </summary>
/// 
namespace QzEbook.ReWrite
{
    [Serializable()]
    [XmlRoot("RewriterConfig")]
    public class RewriterConfig
    {
        private RewriterRuleCollection rules;

        public RewriterRuleCollection Rules
        {
            get { return rules; }
            set { rules = value; }
        }

        /// <summary>
        /// 取得配置文件续列化后的对像.
        /// </summary>
        /// <returns>就是当前对像,含有匹配数组</returns>
        public static RewriterConfig GetConfig()
        {
            RewriterConfig config = HttpContext.Current.Cache["RewriterConfig"] as RewriterConfig;
            if (config== null)
            {
                config=(RewriterConfig)ConfigurationManager.GetSection("RewriterConfig");
                HttpContext.Current.Cache.Insert("RewriterConfig", config);
                
            }
            return config;
        }
    }
}